<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

/**
 * App\Models\BlackList
 *
 * @property int $id
 * @property int|null $member_id 用户
 * @property int|null $position_id 工作
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @property-read \App\Models\Member|null $member
 * @property-read \App\Models\Position|null $position
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BlackList newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BlackList newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BlackList query()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BlackList whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BlackList whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BlackList whereMemberId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BlackList wherePositionId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BlackList whereUpdatedAt($value)
 * @mixin \Eloquent
 */
class BlackList extends Model
{

    protected $fillable=['member_id','position_id'];


    public static function boot()
    {
        parent::boot();
        self::addGlobalScope('default_order', function ($query) {
            /** @var Position $query */
            $query->orderBy('created_at','desc');
        });
    }

    public function member(){
        return $this->belongsTo(Member::class);
    }

    public function position(){
        return $this->belongsTo(Position::class);
    }
}
